﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.Windows.Media.Imaging;
using System.IO.IsolatedStorage;

namespace myChannel9
{
    public partial class Control_Series : UserControl
    {
        public event EventHandler goToSeries;

        public Control_Series()
        {
            InitializeComponent();

            genereateShowList();
        }

        private void genereateShowList()
        {
            //Web Camps TV

            List<ShowObject> list1 = new List<ShowObject>();
            list1.Add(new ShowObject { Heading = "Mix Countd.", Image = "Images/Series_CountdowntoMix.png", Querry = "Countdown to Mix", Rss = "http://channel9.msdn.com/Series/Countdown-to-Mix/RSS" });
            list1.Add(new ShowObject { Heading = "wp7 dev", Image = "Images/Series_WindowsPhone 7DevelopmentforAbsoluteBeginners.png", Querry = "Windows Phone 7 Development for Absolute Beginners", Rss = "http://channel9.msdn.com/Series/Windows-Phone-7-Development-for-Absolute-Beginners/RSS" });
            list1.Add(new ShowObject { Heading = "Belgium 2011", Image = "Images/Series_WebCampBelgium2011.png", Querry = "Web Camp Belgium 2011", Rss = "http://channel9.msdn.com/Series/Web-Camp-Belgium-2011/RSS" });
            list1.Add(new ShowObject { Heading = "Exchange", Image = "Images/Show_Default.png", Querry = "Exchange RPC Protocols Plugfest January 2011", Rss = "http://channel9.msdn.com/Series/Exchange-RPC-Protocols-Plugfest-January-2011/RSS" });
            list1.Add(new ShowObject { Heading = "Azure", Image = "Images/Series_MicrosoftAzureindeEchteWereld.png", Querry = "Microsoft Azure in de Echte Wereld", Rss = "http://channel9.msdn.com/Series/Microsoft-Azure-in-de-Echte-Wereld/RSS" });
            list1.Add(new ShowObject { Heading = "CRM 2011", Image = "Images/Show_Default.png", Querry = "Dynamics CRM 2011 Developer Training", Rss = "http://channel9.msdn.com/Series/DynamicsCRM2011/RSS" });
            list1.Add(new ShowObject { Heading = "mvcConf", Image = "Images/Series_mvcConf.png", Querry = "mvcConf", Rss = "http://channel9.msdn.com/Series/mvcConf/RSS" });
            list1.Add(new ShowObject { Heading = "vs doc.", Image = "Images/Series_TheVisualStudioDocumentary.png", Querry = "The Visual Studio Documentary", Rss = "http://channel9.msdn.com/Series/VisualStudioDocumentary/RSS" });
            lboSeries1.ItemsSource = list1;

            List<ShowObject> list2 = new List<ShowObject>();
            list2.Add(new ShowObject { Heading = "campus tour", Image = "Images/Series_MicrosoftCampusTours.png", Querry = "Microsoft Campus Tours", Rss = "http://channel9.msdn.com/Series/CampusTours/RSS" });   
            list2.Add(new ShowObject { Heading = "SP Firestarter", Image = "Images/Series_SharePoint2010Firestarter.png", Querry = "SharePoint 2010 Firestarter", Rss = "http://channel9.msdn.com/Series/SharePoint-2010-Firestarter/RSS" });
            list2.Add(new ShowObject { Heading = "ALM Summit", Image = "Images/Series_ALMSummit2010.png", Querry = "ALM Summit 2010", Rss = "http://channel9.msdn.com/Series/ALM-Summit-2010/RSS" });
            list2.Add(new ShowObject { Heading = "Unified com.", Image = "Images/Show_Default.png", Querry = "Unified Communications 14 Labs", Rss = "http://channel9.msdn.com/Series/Unified-Communications-14-Labs/RSS" });
            list2.Add(new ShowObject { Heading = "SL Firestarter", Image = "Images/Series_SilverlightFirestarter2010.png", Querry = "Silverlight Firestarter", Rss = "http://channel9.msdn.com/Series/Silverlight-Firestarter/RSS" });
            list2.Add(new ShowObject { Heading = "full stack", Image = "Images/Series_TheFullStack.png", Querry = "The Full Stack", Rss = "http://channel9.msdn.com/Series/The-Full-Stack/RSS" });
            list2.Add(new ShowObject { Heading = "Windows AD", Image = "Images/Show_Default.png", Querry = "Windows AD Protocols Plugfest 2011", Rss = "http://channel9.msdn.com/Series/Windows-AD-Protocols-Plugfest-2011/RSS" });
            list2.Add(new ShowObject { Heading = "ms history", Image = "Images/Series_TheHistoryOfMicrosoft.png", Querry = "The History Of Microsoft", Rss = "http://channel9.msdn.com/Series/History/RSS" });
            lboSeries2.ItemsSource = list2;
        }

        private void lboSeries1_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            ShowObject show = lboSeries1.SelectedItem as ShowObject;

            if (show != null)
            {
                if (IsolatedStorageSettings.ApplicationSettings.Contains("Show"))
                    IsolatedStorageSettings.ApplicationSettings["Show"] = show;
                else
                    IsolatedStorageSettings.ApplicationSettings.Add("Show", show);

                goToSeries(show, new EventArgs());
                lboSeries1.SelectedIndex = -1;
            }
        }

        private void lboSeries2_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            ShowObject show = lboSeries2.SelectedItem as ShowObject;

            if (show != null)
            {
                if (IsolatedStorageSettings.ApplicationSettings.Contains("Show"))
                    IsolatedStorageSettings.ApplicationSettings["Show"] = show;
                else
                    IsolatedStorageSettings.ApplicationSettings.Add("Show", show);

                goToSeries(show, new EventArgs());
                lboSeries2.SelectedIndex = -1;
            }
        }

    }
}
